<!--
 @description 指标说明
 @fileName TargetInstrusction.vue
 @author zengqiongying
 @created 2021/07/30 11:12:39
-->
<template>
  <van-popup v-model="dialogShow" round class="custom-van-pop">
    <div class="popup-title">
      <img src="@/assets/image/win_title_bg.png">
      <div class="txt">{{ title }}<span class="c-yellow">数据说明</span></div>
    </div>
    <div class="popup-content">
      <template v-if="dataList.length">
        <div v-for="(item,index) in dataList" :key="index" class="item-group">
          <div v-if="item.title" class="group-title">{{ item.title }}</div>
          <div v-if="item.content" class="item-content">{{ item.content }}</div>
          <div v-if="item.remark" class="item-remark">{{ item.remark }}</div>
          <template v-if="item.child">
            <div v-for="(child,cIndex) in item.child" :key="cIndex" class="item-subwrap">
              <div v-if="child.title" class="item-sub-title">{{ cIndex +1 }}.{{ child.title }}</div>
              <div class="item-content">
                {{ child.content }}
              </div>
              <div v-if="item.remark" class="item-remark">{{ item.remark }}</div>
            </div>
          </template>
        </div>
      </template>
      <div v-else>暂无数据</div>
    </div>
    <div class="popup-close" @click="dialogShow=false">
      <img src="@/assets/image/icon_close@2x.png">
    </div>
  </van-popup>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex'
import introData from '@/const/instrusction/index'
export default {
  name: 'TargetInstrusction',
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {

    }
  },

  computed: {
    dialogShow: {
      get() {
        return this.showIntro
      },
      set(val) {
        // this.$emit('update:visible', val)
        this.updateIntroData({ show: false })
      }
    },
    ...mapGetters(['introCode', 'introType', 'showIntro']),
    title() {
      if (introData && introData[this.introCode]) {
        return introData[this.introCode].title || ''
      }
      return ''
    },
    dataList() {
      if (introData && introData[this.introCode] && introData[this.introCode].data) {
        const data = introData[this.introCode].data
        return data[this.introType] || []
      }
      return []
    }
  },
  created() {},
  methods: {
    ...mapMutations(['updateIntroData'])
  }
}

</script>
<style lang='less' scoped>
  .custom-van-pop{
    width: 85%;
    border-radius: 8px !important;
    background:transparent !important;
    margin-top:23PX;
  }
  .popup-title{
    position: relative;
    height: 58px;
    background:#FFFFFF;
    font-size:18px;
    letter-spacing: 2px;
    color: #fff;
    font-family: 'PFZH';
    img{
      width: 100%;
    }
    .txt{
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      display:flex;
      justify-content: center;
      align-items: center;
    }
    .c-yellow{
      color:#FFF6A5 ;
    }
  }
  .popup-content{
    border-radius:0 0 8px 8px;
    padding:15px;
    background:#fff;
    color: #555555;
    line-height: 20px;
    font-size: 12px;
    letter-spacing: 1px;
    max-height:70vh;
    box-sizing: border-box;
    overflow-y:auto;
  }
  .popup-close{
    width: 26px;
    height: 26px;
    margin: 20px auto 0;
    img{
      width: 26px;
      height: 26px;
    }
  }
  .item-group{
    border-bottom: 1px solid #F3F4F5;
    padding-bottom: 15px;
    margin-bottom: 15px;
    &:last-child{
      border-bottom: 0;
      margin-bottom: 0;
    }
    .group-title{
      position: relative;
      padding-left: 15px;
      height: 20px;
      line-height: 20px;
      font-size: 14px;
      color: #333333;
      font-weight: bold;
      margin-bottom: 10px;
      &::before{
        content: '';
        position: absolute;
        left: 0;
        top: 5px;
        width: 10px;
        height: 10px;
        background: #FFFFFF;
        border: 2px solid #12B9A3;
        box-sizing: border-box;
        border-radius: 50%;
      }
    }
    .item-subwrap{
      margin-bottom: 10px;
      &:last-child{
        margin-bottom: 0;
      }
    }
    .item-sub-title{
      line-height:16px;
      font-size: 12px;
      color: #333333;
      font-weight: bold;
      margin-bottom: 10px;
    }
    .item-content{
      margin-bottom:10px;
      &:last-child{
        margin-bottom: 0;
      }
    }
    .item-remark{
      font-size:10px;
      color:red
    }
  }
</style>
